package net.lab1024.sa.admin.module.business.erp.poo.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import net.lab1024.sa.admin.module.business.erp.poo.domain.form.PoordaAddForm;
import net.lab1024.sa.admin.module.business.erp.poo.domain.form.PoordaQueryForm;
import net.lab1024.sa.admin.module.business.erp.poo.domain.form.PoordaUpdateForm;
import net.lab1024.sa.admin.module.business.erp.poo.domain.vo.PoordaVO;
import net.lab1024.sa.admin.module.business.erp.poo.service.PoordaService;
import net.lab1024.sa.base.common.domain.PageResult;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 采购订单行 Controller
 *
 * @Author AKITA
 * @Date 2025-08-18 09:11:53
 * @Copyright AKITA
 */

@RestController
@Tag(name = "采购订单行")
public class PoordaController {

    @Resource
    private PoordaService poordaService;

    @Operation(summary = "分页查询 @author AKITA")
    @PostMapping("/poorda/queryPage")
    public ResponseDTO<PageResult<PoordaVO>> queryPage(@RequestBody @Valid PoordaQueryForm queryForm) {
        return ResponseDTO.ok(poordaService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author AKITA")
    @PostMapping("/poorda/add")
    public ResponseDTO<String> add(@RequestBody @Valid PoordaAddForm addForm) {
        return poordaService.add(addForm);
    }

    @Operation(summary = "更新 @author AKITA")
    @PostMapping("/poorda/update")
    public ResponseDTO<String> update(@RequestBody @Valid PoordaUpdateForm updateForm) {
        return poordaService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author AKITA")
    @PostMapping("/poorda/batchDelete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
        return poordaService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author AKITA")
    @GetMapping("/poorda/delete/{id}")
    public ResponseDTO<String> batchDelete(@PathVariable Long id) {
        return poordaService.delete(id);
    }
}
